.class public Lcom/zuimeia/ui/view/ZMHorizontalScrollView;
.super Landroid/widget/HorizontalScrollView;
.source "ZMHorizontalScrollView.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;
    }
.end annotation


# instance fields
.field mLastEventX:F

.field private mLocalOverScroller:Landroid/widget/OverScroller;

.field mMaxOverX:I

.field mMaxScroll:I

.field private mOnOverScrolledListener:Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;

.field private mOverScroller:Landroid/widget/OverScroller;

.field private mOverX:I

.field mScrollX:I

.field mScrollY:I

.field mScrolling:Z

.field mToRight:Z


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 2
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 24
    invoke-direct {p0, p1}, Landroid/widget/HorizontalScrollView;-><init>(Landroid/content/Context;)V

    .line 25
    invoke-direct {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->init()V

    .line 26
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;)V
    .registers 3
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "attrs"    # Landroid/util/AttributeSet;

    .prologue
    .line 29
    invoke-direct {p0, p1, p2}, Landroid/widget/HorizontalScrollView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;)V

    .line 30
    invoke-direct {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->init()V

    .line 31
    return-void
.end method

.method public constructor <init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V
    .registers 4
    .param p1, "context"    # Landroid/content/Context;
    .param p2, "attrs"    # Landroid/util/AttributeSet;
    .param p3, "defStyleAttr"    # I

    .prologue
    .line 34
    invoke-direct {p0, p1, p2, p3}, Landroid/widget/HorizontalScrollView;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;I)V

    .line 35
    invoke-direct {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->init()V

    .line 36
    return-void
.end method

.method private init()V
    .registers 6

    .prologue
    .line 39
    new-instance v3, Landroid/widget/OverScroller;

    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getContext()Landroid/content/Context;

    move-result-object v4

    invoke-direct {v3, v4}, Landroid/widget/OverScroller;-><init>(Landroid/content/Context;)V

    iput-object v3, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLocalOverScroller:Landroid/widget/OverScroller;

    .line 41
    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getContext()Landroid/content/Context;

    move-result-object v3

    invoke-static {v3}, Landroid/view/ViewConfiguration;->get(Landroid/content/Context;)Landroid/view/ViewConfiguration;

    move-result-object v0

    .line 42
    .local v0, "configuration":Landroid/view/ViewConfiguration;
    invoke-virtual {v0}, Landroid/view/ViewConfiguration;->getScaledOverflingDistance()I

    move-result v3

    iput v3, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOverX:I

    .line 45
    :try_start_19
    invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/Class;->getSuperclass()Ljava/lang/Class;

    move-result-object v3

    const-string v4, "mScroller"

    invoke-virtual {v3, v4}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;

    move-result-object v2

    .line 46
    .local v2, "field":Ljava/lang/reflect/Field;
    const/4 v3, 0x1

    invoke-virtual {v2, v3}, Ljava/lang/reflect/Field;->setAccessible(Z)V

    .line 47
    invoke-virtual {v2, p0}, Ljava/lang/reflect/Field;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v3

    check-cast v3, Landroid/widget/OverScroller;

    iput-object v3, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOverScroller:Landroid/widget/OverScroller;
    :try_end_33
    .catch Ljava/lang/Exception; {:try_start_19 .. :try_end_33} :catch_34

    .line 52
    .end local v2    # "field":Ljava/lang/reflect/Field;
    :goto_33
    return-void

    .line 48
    :catch_34
    move-exception v1

    .line 49
    .local v1, "e":Ljava/lang/Exception;
    invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_33
.end method


# virtual methods
.method public computeScroll()V
    .registers 9

    .prologue
    const/4 v6, 0x1

    const/4 v7, 0x0

    .line 102
    iget-object v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLocalOverScroller:Landroid/widget/OverScroller;

    invoke-virtual {v5}, Landroid/widget/OverScroller;->computeScrollOffset()Z

    move-result v5

    if-eqz v5, :cond_4e

    .line 103
    iput-boolean v6, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mScrolling:Z

    .line 104
    iget v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mScrollX:I

    .line 105
    .local v0, "oldX":I
    iget v1, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mScrollY:I

    .line 106
    .local v1, "oldY":I
    iget-object v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLocalOverScroller:Landroid/widget/OverScroller;

    invoke-virtual {v5}, Landroid/widget/OverScroller;->getCurrX()I

    move-result v3

    .line 107
    .local v3, "x":I
    iget-object v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLocalOverScroller:Landroid/widget/OverScroller;

    invoke-virtual {v5}, Landroid/widget/OverScroller;->getCurrY()I

    move-result v4

    .line 109
    .local v4, "y":I
    if-ne v0, v3, :cond_20

    if-eq v1, v4, :cond_31

    .line 110
    :cond_20
    iget-object v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOnOverScrolledListener:Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;

    if-eqz v5, :cond_31

    .line 111
    if-gez v3, :cond_38

    .line 112
    int-to-float v5, v3

    iget v6, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mMaxOverX:I

    int-to-float v6, v6

    div-float v2, v5, v6

    .line 113
    .local v2, "percent":F
    iget-object v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOnOverScrolledListener:Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;

    invoke-interface {v5, v3, v2}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;->onOverScrolled(IF)V

    .line 124
    .end local v2    # "percent":F
    :cond_31
    :goto_31
    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->postInvalidate()V

    .line 138
    .end local v0    # "oldX":I
    .end local v1    # "oldY":I
    .end local v3    # "x":I
    .end local v4    # "y":I
    :cond_34
    :goto_34
    invoke-super {p0}, Landroid/widget/HorizontalScrollView;->computeScroll()V

    .line 140
    return-void

    .line 115
    .restart local v0    # "oldX":I
    .restart local v1    # "oldY":I
    .restart local v3    # "x":I
    .restart local v4    # "y":I
    :cond_38
    iget v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mMaxScroll:I

    sub-int v5, v3, v5

    if-lez v5, :cond_31

    .line 116
    iget v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mMaxScroll:I

    sub-int v5, v3, v5

    int-to-float v5, v5

    iget v6, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mMaxOverX:I

    int-to-float v6, v6

    div-float v2, v5, v6

    .line 117
    .restart local v2    # "percent":F
    iget-object v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOnOverScrolledListener:Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;

    invoke-interface {v5, v3, v2}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;->onOverScrolled(IF)V

    goto :goto_31

    .line 128
    .end local v0    # "oldX":I
    .end local v1    # "oldY":I
    .end local v2    # "percent":F
    .end local v3    # "x":I
    .end local v4    # "y":I
    :cond_4e
    iget-boolean v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mScrolling:Z

    if-ne v5, v6, :cond_34

    .line 129
    iget-object v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOnOverScrolledListener:Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;

    if-eqz v5, :cond_5c

    .line 130
    iget-object v5, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOnOverScrolledListener:Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;

    const/4 v6, 0x0

    invoke-interface {v5, v7, v6}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;->onOverScrolled(IF)V

    .line 133
    :cond_5c
    iput-boolean v7, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mScrolling:Z

    goto :goto_34
.end method

.method public onTouchEvent(Landroid/view/MotionEvent;)Z
    .registers 17
    .param p1, "ev"    # Landroid/view/MotionEvent;

    .prologue
    .line 69
    invoke-super/range {p0 .. p1}, Landroid/widget/HorizontalScrollView;->onTouchEvent(Landroid/view/MotionEvent;)Z

    move-result v12

    .line 70
    .local v12, "ret":Z
    invoke-virtual/range {p1 .. p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v0

    const/4 v1, 0x1

    if-ne v0, v1, :cond_5f

    .line 71
    iget-object v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOverScroller:Landroid/widget/OverScroller;

    invoke-virtual {v0}, Landroid/widget/OverScroller;->isFinished()Z

    move-result v0

    if-nez v0, :cond_5f

    .line 73
    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getWidth()I

    move-result v0

    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getPaddingLeft()I

    move-result v1

    sub-int/2addr v0, v1

    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getPaddingRight()I

    move-result v1

    sub-int v14, v0, v1

    .line 74
    .local v14, "width":I
    const/4 v0, 0x0

    invoke-virtual {p0, v0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getChildAt(I)Landroid/view/View;

    move-result-object v0

    invoke-virtual {v0}, Landroid/view/View;->getWidth()I

    move-result v13

    .line 75
    .local v13, "right":I
    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getWidth()I

    move-result v0

    div-int/lit8 v0, v0, 0x5

    iput v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mMaxOverX:I

    .line 76
    const/4 v0, 0x0

    sub-int v1, v13, v14

    invoke-static {v0, v1}, Ljava/lang/Math;->max(II)I

    move-result v0

    iput v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mMaxScroll:I

    .line 77
    iget-object v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLocalOverScroller:Landroid/widget/OverScroller;

    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getScrollX()I

    move-result v1

    invoke-virtual {p0}, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->getScrollY()I

    move-result v2

    iget-boolean v3, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mToRight:Z

    if-eqz v3, :cond_7a

    const/4 v3, -0x1

    :goto_4b
    iget-object v4, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOverScroller:Landroid/widget/OverScroller;

    invoke-virtual {v4}, Landroid/widget/OverScroller;->getCurrVelocity()F

    move-result v4

    float-to-int v4, v4

    mul-int/2addr v3, v4

    const/4 v4, 0x0

    const/4 v5, 0x0

    iget v6, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mMaxScroll:I

    const/4 v7, 0x0

    const/4 v8, 0x0

    iget v9, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mMaxOverX:I

    const/4 v10, 0x0

    invoke-virtual/range {v0 .. v10}, Landroid/widget/OverScroller;->fling(IIIIIIIIII)V

    .line 81
    .end local v13    # "right":I
    .end local v14    # "width":I
    :cond_5f
    invoke-virtual/range {p1 .. p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v0

    const/4 v1, 0x2

    if-ne v0, v1, :cond_79

    .line 82
    invoke-virtual/range {p1 .. p1}, Landroid/view/MotionEvent;->getX()F

    move-result v11

    .line 83
    .local v11, "curX":F
    iget v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLastEventX:F

    cmpl-float v0, v11, v0

    if-lez v0, :cond_7c

    .line 84
    const/4 v0, 0x1

    iput-boolean v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mToRight:Z

    .line 91
    :cond_73
    :goto_73
    invoke-virtual/range {p1 .. p1}, Landroid/view/MotionEvent;->getX()F

    move-result v0

    iput v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLastEventX:F

    .line 94
    .end local v11    # "curX":F
    :cond_79
    return v12

    .line 77
    .restart local v13    # "right":I
    .restart local v14    # "width":I
    :cond_7a
    const/4 v3, 0x1

    goto :goto_4b

    .line 85
    .end local v13    # "right":I
    .end local v14    # "width":I
    .restart local v11    # "curX":F
    :cond_7c
    iget v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLastEventX:F

    cmpg-float v0, v11, v0

    if-gez v0, :cond_73

    .line 86
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mToRight:Z

    goto :goto_73
.end method

.method public setOnOverScrolledListener(Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;)V
    .registers 2
    .param p1, "listener"    # Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;

    .prologue
    .line 143
    iput-object p1, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mOnOverScrolledListener:Lcom/zuimeia/ui/view/ZMHorizontalScrollView$OnOverScrolledListener;

    .line 144
    return-void
.end method

.method public stopOverScroll()V
    .registers 2

    .prologue
    .line 59
    iget-object v0, p0, Lcom/zuimeia/ui/view/ZMHorizontalScrollView;->mLocalOverScroller:Landroid/widget/OverScroller;

    invoke-virtual {v0}, Landroid/widget/OverScroller;->abortAnimation()V

    .line 60
    return-void
.end method
